<template>
	<view class="pageBg">
		<headerView title="我的名片">
			<view class="skip" @click="goHome">跳过</view>
		</headerView>
		<view class="tab flex">
			<view class="title itemAct">个人资料</view>
			<view class="line" :class="this.tabIndex > 0 ? 'itemAct' : ''"></view>
			<view class="title" :class="this.tabIndex > 0 ? 'itemAct' : ''">企业信息</view>
		</view>
		<personalData v-show="tabIndex === 0" @next="skip" :fromData="fromData"></personalData>
		<enterprise v-show="tabIndex === 1" @next="skip" :fromData="fromData"></enterprise>
	</view>
</template>

<script>
	import personalData from '@/components/my/card/personalData/personalData.vue';
	import enterprise from '@/components/my/card/enterprise/enterprise.vue';
	export default {
		components: {
			personalData,
			enterprise,
		},
		data() {
			return {
				tabIndex: 0,
				fromData: {},
				data: {},
			};
		},
		onLoad(options) {
			const { business_status } = uni.getStorageSync('loginData');
			if (business_status == 0) {
				return;
			}
			this.init();
		},
		methods: {
			async init() {
				const res = await this.$api.CardBusinessMi();
				this.fromData = res.data;
			},
			skip(index) {
				if (index == 2) {
					this.initLogin();

					uni.navigateTo({
						url: '/pages/my/card/success',
					});
					return;
				}
				this.tabIndex = index;
			},
			goHome() {
				uni.reLaunch({
					url: '/pages/index/index',
				});
			},
		},
	};
</script>
<style lang="scss" scoped>
	.pageBg {
		background: #fff;
		padding-bottom: calc(var(--window-bottom) + 146rpx);

		.skip {
			color: #999999;
			font-size: $uni-font-size-12;
		}

		.tab {
			width: 474rpx;
			margin: 0 auto;
			justify-content: space-between;
			align-items: center;
			color: #999999;
			font-size: $uni-font-size-14;

			.line {
				width: 200rpx;
				height: 0rpx;
				opacity: 1;
				border-top: 1rpx solid #dddddd;
			}

			.itemAct {
				color: $price-color;
				border-color: $price-color;
			}
		}
	}
</style>